home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 051-075 / scopedisk52 / tutor / c6 < prev    next >
Text File  |  1995-03-18  |  10KB  |  280 lines

  1. Odds and Ends in this section:
  2.  
  3. REDIRECTION
  4. NIL and PRT DEVICES
  5. ESCAPE CODES
  6. STRIPPING A WORKBENCH
  7. ________________________________________________________________________________
  8.  
  9. REDIRECTION
  10.  
  11.     the process by which you can channel input/output from/to an alternate
  12.     source
  13.  
  14.     That didn't make too much sense, so I'll try again.
  15.  
  16.     There are two operators for redirection, the "greater than" > and
  17. the "less than" < keys.
  18.  
  19.     More accurately the ">" key is the output operator /* write to */
  20. and the "<" key is the input operator /* read from */.
  21.  
  22.     By using these keys between the command and the pathname, AmigaDOS
  23. "redirects" the I/O /* Input/Output */ in accordance with your directions.
  24. There may be more than one argument required by the command but the redirection
  25. string would still go right after the command.
  26.  
  27.     We've use redirection a few times before, but let's have another look at
  28. one example again:
  29.  
  30. >> DIR >ram:a
  31. /* we'll get drive activity but no output to the screen */
  32. >> DIR ram:
  33.   c (dir)
  34. a
  35. /* there might be other junk here, too. you can clean it up on your own later */
  36.  
  37. >> TYPE <ram:a
  38. /* a normal DIR listing */
  39.  
  40.     Frankly, and this may be due to lack of imagination, but I haven't found
  41. too much use for the "read from" function. In the situation above, it would also
  42. have worked by just using the TYPE command alone.
  43.     However, ">" is very useful. As you've seen above, it will "capture"
  44. fleeting displays to be perused at your leisure.
  45.     It can also discard displays you might find distracting or inconvenient.
  46. Some programs begin with a flourish. They can display anything from a simple
  47. usage statement to opening windows that pay homage to their creator.
  48.     Should you find yourself in the situation of wanting to dispose of
  49. little thorns in your bed of roses, we'll use our redirect and a unique device.
  50.             NIL:
  51.  
  52. ________________________________________________________________________________
  53.  
  54. NIL and PRT DEVICES
  55.  
  56.     NIL: pseudo-device that just returns an End-of-File (EOF)
  57.     PRT: the device that is configured through "preferences" and handles
  58. output to your printer.
  59.  
  60.     NIL: first...
  61.  
  62.     If it's a device, why doesn't it show up at the end of an ASSIGN LIST
  63. command? Why isn't it mounted? Where is it?
  64.  
  65.     I don't know. But it works as advertised.
  66.  
  67.     NIL: will take input from anywhere....and throw it away.
  68.  
  69.     Just as an example, since AmigaDOS commands don't really fit the
  70. catagories described above.
  71.  
  72. >> DIR >nil: 
  73. /* same old disk activity */
  74. >> DIR nil:
  75. nil: not found
  76.  
  77.     If you noticed that there isn't a filename specified in the redirection
  78. line, good for you. So try it with a filename:
  79.  
  80. >> DIR >nil:a
  81. /* as soon as you hit <RETURN> you should have gotten a system requester asking
  82. that you insert volumn "nil" in any drive. Hit cancel */
  83. CLI error: Unable to open redirection file
  84.  
  85.  
  86.     Way back when if you watched the movie mentioned in the intro section,
  87. the program Projector begins by printing out a message. To prevent a message of
  88. this nature from being displayed, you'd start the program:
  89.  
  90. BS> projector >nil: filename.film
  91.  
  92.     This techique will only throw away the display and won't interfere with
  93. the normal operation of the program.
  94.  
  95.  
  96.  
  97.     PRT:
  98.  
  99.     Files can be sent to PRT: in several ways. You can:
  100.  
  101. BS> COPY [pathname/]filename prt:
  102. or
  103. BS> TYPE [pathname/]filename >prt:
  104.  
  105.     You can also type straight to the printer from the keyboard by:
  106.  
  107. BS> COPY * >prt:
  108. /* the cursor will disappear now */
  109. /* the "*" here represents the screen/console, but if you're using the ARP
  110. commands this method won't work since the "*" is a wildcard. */
  111.  
  112.     To exit this mode, type <CTLR>\ /* control + back slash */. When you do
  113. this your cursor will re-appear.
  114.  
  115. ________________________________________________________________________________
  116.  
  117. ESCAPE CODES
  118.  
  119.     The CLI has a great many similarities with a printer, but it's more
  120. versatile. By sending it what is known as a command sequence indicator (CSI) to
  121. it, it will produce some of the same effects the a printer. The CSI is the
  122. <ESC> key.
  123.  
  124.     As was mentioned in the tutorial.5, ED doesn't allow <ESC> to be entered
  125. directly but you saw how we could get around that. You may have also noticed a
  126. few other "*somethings" in the file. Here's what they do:
  127.  
  128.     *E = <ESC>
  129.     *F = <FF>
  130.     *N = <LF>
  131.     *T = <TAB> 
  132.     *V = <VTAB> 
  133.  
  134. /* e=escape, f=formfeed, n=linefeed(return), t=tab, v=vertical tab */
  135.  
  136.     One thing to remember is that, all these commands do is change the way
  137. the display is handled. They don't effect any change on the results of a
  138. command, except where, as in the case of our example with the startup-sequence,
  139. we might inadvertently mess up the syntax.
  140.  
  141.     Escape codes can be used to change the style of print:
  142.          reversed 
  143.         bold
  144.         italics
  145.         underlined
  146.  
  147.     They can change  the  color .
  148.  
  149.     They can be used with almost any command that receives it's arguments in
  150. quotes, an exception being NEWCLI. The commands I've used most are ECHO and
  151. PROMPT. TYPE will just print /* display */ a file, if the textfile contains
  152. escape codes, TYPE doesn't care, but the display IS changed.
  153.  
  154.     Escape code syntax is:
  155. "<ESC>[ /* a number[s] specifing the effect *//* a terminal character */
  156.  
  157.     For example, "<ESC>[0m", turns off the effect of previously used escape
  158. codes. Try this:
  159.  
  160. >> echo "*e[33mHow did it work?"
  161. How did it work?
  162. >> /* type a few letters here, then <CTRL>X to erase the line */
  163.  
  164.     What we did there was check that the second line was the original color.
  165. So when do we need to delimit the effects?
  166.  
  167. >> echo "*e[33;42mHow did it work?"
  168. /* now we've ended up with a full screen outofcontrol line across the screen
  169. under our test line, since that wasn't what we wanted, we can insure that this
  170. sort of thing doesn't happen by delimiting the effect */
  171.  
  172. >> echo "*e[33;42mHow did it work?*e[0m"
  173. How did it work?
  174.  
  175.     Here are the escape codes I've found. This isn't necessarily all of
  176. them, you can experiment around with your printer manual, which will usually
  177. have a list of escape codes that it recognizes, and try to find something that
  178. would give you any results you can't get with these.
  179.  
  180. ________________________________________________________________________________
  181.  
  182.       Escape Codes      
  183.  
  184. with ED
  185.     /* *E==<ESC>
  186.        *F==<FF>
  187.        *N==<LF>
  188.        *T==<TAB>
  189.        *V==<Vert tab> */
  190.  
  191.  
  192. use ";" to seperate multiple codes
  193.  
  194. <ESC>[0m =reset/cancel
  195.  
  196. Type Styles:
  197. <ESC>[1m =bold characters
  198. <ESC>[3m =italics
  199. <ESC>[4m =underlined
  200. <ESC>[7m =<ESC>[30;41m
  201. <ESC>[8m =(puts "cursors" of register 3 at beginning and end of 
  202.        blank line of the same length as spaces between this command and
  203.        the delimiter)
  204.  
  205. Colors:
  206. <ESC>[30m =set foreground to register 0 (background color)
  207. <ESC>[31m =foreground to register 1 (border & main body of disk icon)
  208. <ESC>[32m =foreground to register 2 (border of disk icon)
  209. <ESC>[33m =foreground to register 3 (general highlights & flap on disk icon)
  210. <ESC>[34m-<ESC>[39m =repeat as above
  211. <ESC>[40m =set background to register 0
  212. <ESC>[41m =background to register 1
  213. <ESC>[42m =background to register 2
  214. <ESC>[43m =background to register 3
  215. <ESC>[44m-<ESC>[49m =repeat as above
  216.  
  217. Prompt:
  218. <ESC>[0<SPACE>p=turns cursor off
  219. <ESC>[<SPACE>p=turns cursor on
  220.  
  221.  
  222. ________________________________________________________________________________
  223.  
  224. STRIPPING A WORKBENCH
  225.  
  226.     This blurb will discuss some of the ways that you can take a standard
  227. workbench and remove some of the things you might not need. This will create
  228. more room on the disk for you to install new commands as you find them.
  229.  
  230.                WARNING !!!      
  231. DO NOT DO THIS TO YOUR ORIGINAL WORKBENCH DISK, ALWAYS WORK ON A COPY !!!
  232.  
  233.     As a suggestion before we start, I have complete disks that mirror some
  234. of the directories found on the workbench. "C" and "fonts" in particular.
  235. Before I removed some of this stuff from my workbench, I copied it to the disks.
  236. This way I can still have the more essential items at my disposal. There are
  237. lots of commands and fonts out there and by using the ASSIGN, CD, or PATH
  238. commands it's easy to use external /* not on the workbench */ directories.
  239.  
  240.     I have decided the best way to go about this is to make up a seperate
  241. file describing the operation. If you want to continue, copy the file
  242.         "WB_axe"
  243. to the copy of the workbench you're going to have at. Reboot with that disk,
  244. break the startup-sequence with <CTRL>D, RUN ED, and TYPE WB_axe. This
  245. operation can be done from a batchfile, so that's the way we're going to do it.
  246. WB_axe will lead you through editing the batchfile we're going to need to
  247. perform the surgery, but if you're interested in creating the disks I mentioned 
  248. above, you'll have to do that on your own.
  249.     The operation of copying the directories over is different from a
  250. single drive to a multiple drive system, so since you know what you're
  251. working with and I don't...you handle it.
  252.     /* Either way you can do it with something like:
  253.  
  254. BS> copy wb:directory diskname: all
  255.  
  256.     using diskname instead of a drive number allows the single drive folks
  257. to use it too */
  258.  
  259.     It might be easier for you if you print out the file "WB_axe". Then you
  260. won't have to RUN ED to do the job or mess with TYPEing it.
  261. ________________________________________________________________________________
  262.  
  263.     I guess that about does it. Hopefully this has been so some help to you
  264. in understanding a little better how the CLI works and how to use it. Once
  265. again, you'll be steps ahead if you purchase the two books mentioned at the
  266. beginning of all this. They were written by people with the support of
  267. Commodore-Amiga and should be considered the definitive works on the subject.
  268.  
  269.     At any rate, the text files I've written can be distributed to anyone
  270. that might find them helpful as long as it's done free of charge. If errors are
  271. found or you have a better way to offer examples, let me know so these changes
  272. might be initiated.
  273.  
  274.     To Ken Grocke, where ever you are, I got your READER from a friend and
  275. it's great. Hopefully, you don't mind its being used for this purpose.
  276.     
  277.     ©1988, J. Petermann
  278.